<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd">
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored = "false"%>



<%@page import="ru.develbureau.server.model.ClientRequestEntity"%>
<%@page import="java.util.List"%>
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%><html>
  <head>
    <title>удобная страница диспечера</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <link type="text/css" rel="stylesheet" href="common.css"/>
    <script type="text/javascript" src="jquery-1.3.2.min.js"></script>
    
    <script type="text/javascript">
	    $(document).ready(function(){
	    	 $('#smsForm').hide();
		});
	    function activateRow(imgId){
			$('#'+imgId).css('visibility', 'visible');
	    }
	
	    function deActivateRow(imgId){
	    	$('#'+imgId).css('visibility','hidden');
	    }
	
	    function showform(from, to, creID){
		    $('#src').html(from);
		    $('#dest').html(to);
		    $('input[name=clientRequestId]').val(creID);
		    $('#smsForm').show();
	    }  
    </script>
  </head>
  
  <jsp:useBean id="clientRequests" 
  			   scope="request" 
  			   type="java.util.List"
  			   class="java.util.ArrayList">
  	</jsp:useBean>
  	<%! public static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");%>
  	<%!
  		String format(Date date){
  			String str = "";
  			try{
  				str = sdf.format(date);
  			}catch(Exception e){
  				
  			}
  			return str;
  		}
  	%>
  	<%! String status(Boolean isOffered){
  			String str = "";
  			if(isOffered!=null && isOffered){
  				str ="inactive";
  			}
  			return str;
  		}
  	%>
  	<%! String mouseOver(Boolean isOffered, Long id){
  			String str = "";
  			if(isOffered==null || !isOffered){
  				str ="activateRow('sms_"+id+"')";
  			}
  			return str;
  		}
  	%>
  	<%! String mouseOut(Boolean isOffered, Long id){
  			String str = "";
  			if(isOffered==null || !isOffered){
  				str ="deActivateRow('sms_"+id+"')";
  			}
  			return str;
  		}
  	%>
  <body>
	<span class="header">Удобная страница диспечера</span>
	<span class="header" style="font-size: 24px; padding-bottom: 40px; padding-top: 0px;">
		Сейчас <%=format(new Date()) %> 
	</span>
		
  	<table class="adminTable">
  		<%	List<ClientRequestEntity> requestList = (List<ClientRequestEntity>)clientRequests;   
  			for(ClientRequestEntity cre : requestList){ 
  		%>
  			<tr class="<%= status(cre.isOffered()) %>" 
  				onmouseover="<%= mouseOver(cre.isOffered(), cre.getId()) %>" 
  				onmouseout="<%= mouseOut(cre.isOffered(), cre.getId()) %>">
  				
  				<td style="padding-left: 100px;">
  					<%=format(cre.getPublishDate()) %>
  				</td>
  				<td>
  					<%=cre.getTime() %>
  				</td>
  				<td>
  					<%=cre.getSource() %> <span style="font-size: 24px;">&nbsp;&rarr;&nbsp;</span> <%=cre.getTarget() %>
  					<div style="padding-left: 50px; display: inline; line-height: 40px;">
	  					<% if( cre.isOffered() == null || !cre.isOffered() ){ %>
	  							<img id="sms_<%=cre.getId()%>" 
	  								 src="sms.png" class="imgButton" 
	  								 style="visibility: hidden;" 
	  								 onclick="showform('<%=cre.getSource()%>','<%=cre.getTarget()%>','<%=cre.getId()%>')"/>
	  					<% } else if( cre.isAccepted()!=null && cre.isAccepted() ){ %>
	  							<img id="" src="call.png" class="imgButton"/>
	  					<% } %>
  					</div>	
  				</td>
  			</tr>
  		<%}%>
  	</table>
  	
  	<br/>
  	<br/>
  	<br/>
  	<form action="/saveOffer" method="post">
  		<input type="hidden" name="clientRequestId" value="">
  		<div id="smsForm">
	  		<div class="centered" style="background-image: url(/div.png); background-repeat: no-repeat; display: block; width: 532px; height: 220px; margin-left: -300px; ">
	  			<div style="padding-top: 30px; padding-left:50px; font-size: 18px; line-height: 30px;" align="left">
		  			<span id="src">sdgsdfgfsdg</span> &mdash; <span id="dest">sdgsdfgsdfg</span>,<br/>
		  			машина будет в <input name="arrivalTime" type="text" style="border: none;"/><br/>
		  			Стоимость поездки &mdash; <input name="cost" type="text" style="border: none;"/> руб.<br/>
		  			
		  			<div style="font-size: 24px; padding-left: 40px; padding-top: 20px;">
		  				Все верно, <span style="text-decoration: underline; cursor: pointer;" onclick="$('form').submit();">
		  								отправить СМС
		  						   </span>
		  			</div>
		  			<div style="font-size: 12px; padding-right: 20px; padding-bottom: 5px;" align="right">
		  				Не отправлять, <span style="text-decoration: underline; cursor: pointer;" onclick="$('#smsForm').hide();">
		  									закрыть форму
		  							   </span>
		  			</div>
	  			</div>
	  		</div>
  		</div>
  	</form>
  		
  </body>
</html>